//
//  LCFirstRCViewController.m
//  TianXiaShi
//
//  Created by qianfeng01 on 15-7-11.
//  Copyright (c) 2015年 CongCong. All rights reserved.
//

#import "LCFirstRCViewController.h"
#import "FirstRecommendCell.h"
@interface LCFirstRCViewController ()

@end

@implementation LCFirstRCViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.channelId = @"100409-0";
    [self downWebDataWithUrl:[NSString stringWithFormat:@"%@%@%@%@",recommend1,self.channelId,recommend2,self.postionId]];
    [self setRefresh];
}
- (void)creatCollectionView
{
    // 1. 布局对象
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    // flowLayout.itemSize ...
    // flowLayout.sectionInset = ...
    flowLayout.sectionInset = UIEdgeInsetsMake(10, 0, 10, 0);
    
    // 2. 新建collectionView，并关联布局对象
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kScreenSize.width, kScreenSize.height-kScreenSize.height/662*154) collectionViewLayout:flowLayout];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.collectionView.frame];
    //背景图片
    imageView.image = [UIImage imageNamed:@"bgView"];
    self.collectionView.backgroundView = imageView;
    [self.view addSubview:self.collectionView];
    
    // 3. 注册(cell, header, footer)
    [self.collectionView registerNib:[UINib nibWithNibName:@"FirstRecommendCell" bundle:nil] forCellWithReuseIdentifier:@"FirstRecommendCell"];
    [self.collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"Header"];
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    LCBodayModel *bodyModel = self.recommentModel.bodyList[indexPath.row];
    LCVideoModel *model = bodyModel.videoList[0];
    FirstRecommendCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FirstRecommendCell" forIndexPath:indexPath];
    
    [cell showModel:model];
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    return CGSizeMake(kScreenSize.width-20, kScreenSize.height/662*80);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
